import * as types from '../mutation-types'

const user = {
  state: {
    userInfo: {},
    permissionList: [],
    isAdmin: false,
    // exercise: 练习, reporting: 等待报告生成, finished: 练习完成
    exercisePageStatus: 'exercise',
    refreshPageStatus: false, // 是否刷新页面状态
  },
  getters: {
    userInfo(state) {
      return state.userInfo
    },
    isAdmin(state) {
      return state.isAdmin;
    },
  },
  mutations: {
    [types.USER_INFO](state, userInfo) {
      state.userInfo = userInfo
    },

    [types.PERMISSION_LIST](state, permissionList) {
      state.permissionList = permissionList
    },
    [types.EXERCISE_PAGE_STATUS](state, exercisePageStatus) {
      state.exercisePageStatus = exercisePageStatus
    },
    [types.REFRESH_PAGE_STATUS](state, refreshPageStatus) {
      state.refreshPageStatus = refreshPageStatus
    }
  }
}

export default user;
